﻿/*----------------------------------------------------------------
//  <copyright file="IConnectionUserCache.cs" company="MicroCloud@151504200868">
//      Copyright © 2020-2024 MicroCloud Corporation, All rights reserved.
//  </copyright>
//  <site>https://gitee.com/chenmm123/microclouds</site>
//  <last-editor>cmm</last-editor>
//  <last-date>2022-11-15 11:17</last-date>
//----------------------------------------------------------------*/

namespace MicroCloud.AspNetCore.SignalR
{
    #region "SignalR连接用户缓存接口"
    /// <summary>
    /// SignalR连接用户缓存接口
    /// </summary>
    public interface IConnectionUserCache
    {
        #region "方法"
        //用户
        #region "获取缓存的用户信息"
        /// <summary>
        /// 获取缓存的用户信息
        /// </summary>
        /// <param name="userKey">用户标识</param>
        /// <returns></returns>
        Task<ConnectionUser> GetUser(string userKey);
        #endregion
        #region "获取指定用户的所有连接Id"
        /// <summary>
        /// 获取指定用户的所有连接Id
        /// </summary>
        /// <param name="userKey">用户标识</param>
        /// <returns></returns>
        Task<string[]> GetConnectionIds(string userKey);
        #endregion
        #region "设置用户缓存"
        /// <summary>
        /// 设置用户缓存
        /// </summary>
        /// <param name="userKey">用户标识</param>
        /// <param name="user">用户信息</param>
        /// <returns></returns>
        Task<ConnectionUser> SetUser(string userKey, ConnectionUser user);
        #endregion
        #region "添加指定用户的连接"
        /// <summary>
        /// 添加指定用户的连接
        /// </summary>
        /// <param name="userKey">用户标识</param>
        /// <param name="connectionId">连接Id</param>
        /// <returns></returns>
        Task<ConnectionUser> AddConnectionId(string userKey, string connectionId);
        #endregion
        #region "移除指定用户的连接"
        /// <summary>
        /// 移除指定用户的连接
        /// </summary>
        /// <param name="userKey">用户标识</param>
        /// <param name="connectionId">连接Id</param>
        /// <returns></returns>
        Task<ConnectionUser> RemoveConnectionId(string userKey, string connectionId);
        #endregion
        #region "移除指定用户的缓存"
        /// <summary>
        /// 移除指定用户的缓存
        /// </summary>
        /// <param name="userKey">用户标识</param>
        /// <returns></returns>
        Task RemoveUser(string userKey);
        #endregion
        //组
        #region "获取指定用户组信息集合"
        /// <summary>
        /// 获取指定用户组信息集合
        /// </summary>
        /// <param name="userKey">用户标识</param>
        /// <returns></returns>
        List<ConnectionUserGroup> GetUserGroupByUser(string userKey);
        #endregion
        #region "获取指定组用户信息集合"
        /// <summary>
        /// 获取指定组用户信息集合
        /// </summary>
        /// <param name="groupKey">组标识</param>
        /// <returns></returns>
        List<ConnectionUserGroup> GetUserGroupByGroup(string groupKey);
        #endregion
        #region "获取指定连接组信息集合"
        /// <summary>
        /// 获取指定连接组信息集合
        /// </summary>
        /// <param name="connectionId">连接ID</param>
        /// <returns></returns>
        List<ConnectionUserGroup> GetUserGroupByConnection(string connectionId);
        #endregion
        #region "设置用户组"
        /// <summary>
        /// 设置用户组
        /// </summary>
        /// <param name="userGroup">用户组</param>
        /// <returns></returns>
        ConnectionUserGroup SetUserGroup(ConnectionUserGroup userGroup);
        #endregion
        #region "添加指定的用户组"
        /// <summary>
        /// 添加指定的用户组
        /// </summary>
        /// <param name="userKey">用户标识</param>
        /// <param name="groupKey">组标识</param>
        /// <param name="connectionId">连接Id</param>
        /// <returns></returns>
        ConnectionUserGroup AddUserGroup(string userKey, string groupKey, string connectionId);
        #endregion
        #region "移除指定的用户组"
        /// <summary>
        /// 移除指定的用户组
        /// </summary>
        /// <param name="userKey">用户标识</param>
        /// <param name="groupKey">组标识</param>
        /// <param name="connectionId">连接Id</param>
        void RemoveUserGroup(string userKey, string groupKey, string connectionId);
        #endregion
        #region "移除指定用户的用户组信息"
        /// <summary>
        /// 移除指定用户的用户组信息
        /// </summary>
        /// <param name="userKey">用户标识</param>
        void RemoveUserGroupByUser(string userKey);
        #endregion
        #region "移除指定组的用户组信息"
        /// <summary>
        /// 移除指定组的用户组信息
        /// </summary>
        /// <param name="groupKey">组标识</param>
        void RemoveUserGroupByGroup(string groupKey);
        #endregion
        #region "移除指定连接的用户组信息"
        /// <summary>
        /// 移除指定连接的用户组信息
        /// </summary>
        /// <param name="connectionId">连接ID</param>
        void RemoveUserGroupByConnection(string connectionId);
        #endregion

        #endregion

    }
    #endregion

}
